/**
 * Copyright 2014 xiaojian
 *
 *
 * Create on 2015-5-17 下午12:44:46
 */
package xj.toolkit.handler;

import com.google.common.base.Preconditions;

import xj.toolkit.base.ResultCode;
import xj.toolkit.bean.AbstractCommonBean;
import xj.toolkit.bean.tlv.annotation.TlvType;
import xj.toolkit.bean.xip.annotation.SsipField;

/**
 * @author <a href="mailto:caoxiaojian@wasu.com>xiaojian.cao</a>
 * 
 */
public class AbstractResponse<T> extends AbstractCommonBean<T> {
	

	private static final long serialVersionUID = -1089441635492091176L;

	@TlvType(tag = 0)
	@SsipField(index = 0)
	private int code;
	
	@TlvType(tag = 1)
	@SsipField(index = 1)
	private String description;

	public AbstractResponse<T> applyResultCode(ResultCode resultCode) {
		Preconditions.checkArgument(resultCode != null);

		this.code = resultCode.getResultCode();
		this.description = resultCode.getDescription();

		return this;
	}

	/**
	 * @return the code
	 */
	public int getCode() {
		return code;
	}

	/**
	 * @param code
	 *            the code to set
	 */
	public void setCode(int code) {
		this.code = code;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

}
